package com.dwk.rabbitMQ6;

import com.dwk.utils.RabbitMqUtils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

/**
 * 消息消费者
 * 消息接收
 */
public class ReceiverLogs02 {
    private static final String EXCHANGE_NAME = "logs";

    public static void main(String[] args) throws Exception{
        Channel channel = RabbitMqUtils.getChannel();

        //声明一个临时队列
        String queue = channel.queueDeclare().getQueue();
        //绑定交换机
        channel.queueBind(queue,EXCHANGE_NAME,"");
        System.out.println("02等待接收消息");

        DeliverCallback deliverCallback=(consumerTag, message) ->{
            System.out.println(new String(message.getBody(),"UTF-8"));
        };


        channel.basicConsume(queue,true,deliverCallback,consumerTag ->{});
    }
}
